In many computer systems, a graphics processing unit (GPU) is provided as a coprocessor to a central processing unit. The graphics processing unit is specially designed to handle certain kinds of operations efficiently, particularly manipulation of image data and data describing three-dimensional structures. Computer programs running on such computer systems are written to take advantage of the graphics processing unit by specifying operations to be performed by the graphics processing unit and the resources, such as image data, textures and other data structures or data, to be used in those operations. These operations are typically implemented as computer programs, called “shaders”, in a language recognized by the graphics processing unit, called a “shader language”. Example shader languages include, but are not limited to, the high-level shading language (“HLSL”) or the OpenGL shading language (“GLSL”).
A shader compiler processes source code of a computer program written in a shader language, and translates the computer program into compiled code. This compiled code is a set of instructions that can run on a particular graphics processing unit. A shader compiler is itself a computer program that is written based on a number of assumptions about how compiled code is likely to be executed at runtime. These assumptions influence how the shader compiler optimizes the compiled code of a single instance of a shader for performance on a particular GPU architecture. A shader compiler can include a number of options that can be set at compile time to alter the assumptions made by the shader compiler. If these assumptions are incorrect, then the performance of the compiled shader may be less than desired.